<meta charset="UTF-8">
<?php
require 'db_conn.php';
$db->query('set names utf8');
$username=$_POST['username'];
$sex=$_POST['sex'];
$message=$_POST['message'];
$imgurl=$_POST['imgurl'];

$sqlins="insert into t_message (username,sex,message,imgurl) values ('$username','$sex','$message','$imgurl')";
if($db->query($sqlins)){
    echo "<script language='javascript' type='text/javascript'>";
    echo "alert('留言成功！');";
    echo "window.location.href='index.php';";
    echo "</script>";
}else{
     echo '留言不成功！';
}
/*if(empty($username)){
        echo '请输入留言！';
}else{
    $db->query($sqlins);
}*/
